<template>
  <div></div>
</template>

<script>
import { io } from 'socket.io-client'
export default {
  data () {
    return {
      socket: null
    }
  },
  created () {
    this.socket = io('ws://www.baiducom')
    this.socket.on('message', res => {
      console.log(res)
    })
  },
  methods: {
    send () {
      this.socket.emit('send', '发送')
    }
  },
  beforeDestroy () {
    this.socket.close()
    this.socket = null
  }
}
</script>

<style>

</style>
